export const fontStyleConfig = {
  size: {
    type: 'inputNumber',
    label: '字号',
    layout: 'vertical',
    defaultValue: 14,
    options: {
      min: 12
    }
  },
  color: {
    type: 'colorPicker',
    label: '颜色',
    layout: 'vertical',
    defaultValue: '#1e2226'
  },
  weight: {
    type: 'select',
    label: '文字粗细',
    layout: 'vertical',
    defaultValue: 400,
    options: [
      { label: '常规', value: 400 },
      { label: '粗体', value: 600 }
    ]
  }
}

export const titleConfig = {
  titleEnabled: {
    type: 'checkbox',
    title: '图表标题',
    defaultValue: true
  },
  title: {
    when: (v) => v.titleEnabled,
    type: 'object',
    options: {
      name: {
        type: 'input',
        label: '标题名称'
      },
      style: {
        type: 'object',
        label: '标题样式',
        layout: 'inline',
        offset: 0,
        options: fontStyleConfig
      }
    }
  }
}

export const iconConfig = {
  iconEnabled: {
    type: 'checkbox',
    title: '标题图标'
  },
  icon: {
    when: (v) => v.iconEnabled,
    type: 'object',
    label: '图标样式',
    layout: 'inline',
    options: {
      shape: {
        type: 'select',
        label: '形状',
        layout: 'vertical',
        defaultValue: 'splitLine',
        options: [
          { label: '分割线', value: 'splitLine' },
          { label: '实心圆', value: 'circle' }
        ]
      },
      color: {
        type: 'colorPicker',
        label: '颜色',
        layout: 'vertical',
        defaultValue: '#006aff'
      },
      size: {
        type: 'inputNumber',
        label: '大小',
        layout: 'vertical',
        defaultValue: 16,
        options: {
          min: 12,
          max: 40
        }
      }
    }
  }
}

export const splitLineConfig = {
  splitLineEnabled: {
    type: 'checkbox',
    title: '标题分割线'
  },
  splitLine: {
    when: (v) => v.splitLineEnabled,
    type: 'object',
    label: '分割线样式',
    layout: 'inline',
    options: {
      position: {
        type: 'select',
        label: '位置',
        layout: 'vertical',
        defaultValue: 'bottom',
        options: [
          { label: '上方', value: 'top' },
          { label: '下方', value: 'bottom' }
        ]
      },
      color: {
        type: 'colorPicker',
        label: '颜色',
        layout: 'vertical',
        defaultValue: '#e9ecf0'
      },
      width: {
        type: 'inputNumber',
        label: '大小',
        layout: 'vertical',
        defaultValue: 1,
        options: {
          max: 5,
          min: 0
        }
      }
    }
  }
}

export default {
  page: {
    label: '页面',
    options: {
      background: {
        type: 'object',
        layout: 'inline',
        offset: 0,
        options: {
          enabled: {
            type: 'checkbox',
            title: '页面背景',
            defaultValue: true
          },
          color: {
            when: (v) => v.enabled,
            type: 'colorPicker',
            defaultValue: '#f5f7fa'
          }
        }
      },
      padding: {
        type: 'slider',
        label: '页面边距',
        defaultValue: 16,
        options: {
          min: 0,
          max: 40
        }
      }
    }
  },
  chart: {
    label: '图表',
    options: {
      margin: {
        type: 'slider',
        label: '图表间距',
        defaultValue: 16,
        options: {
          min: 0,
          max: 40
        }
      },
      borderRadius: {
        type: 'slider',
        label: '图表圆角',
        defaultValue: 2,
        options: {
          min: 0,
          max: 10
        }
      },
      borderColor: {
        type: 'colorPicker',
        label: '边框颜色',
        defaultValue: '#fff'
      },
      backgroundColor: {
        type: 'colorPicker',
        label: '背景颜色',
        defaultValue: '#fff'
      },
      ...titleConfig,
      ...iconConfig,
      ...splitLineConfig,
      theme: {
        type: 'themePicker',
        label: '图例配色',
        defaultValue: 'rainbow'
      }
    }
  },
  operate: {
    label: '操作栏',
    options: {
      exportImage: {
        type: 'checkbox',
        title: '导出图片',
        defaultValue: true
      },
      exportExcel: {
        type: 'checkbox',
        title: '导出Excel',
        defaultValue: true
      }
    }
  }
}
